#include "include.h"

static uint8_t attidx = 0;
static uint8_t conidx = 0;
static uint8_t svc_id = 0;

void UART_To_BLE(uint8_t *data,uint32_t len)
{
gatt_ntf_t ntf_att;
ntf_att.att_idx = attidx; 
ntf_att.conidx = conidx; 
ntf_att.svc_id = svc_id; 

	co_printf("attidx = %d conidx = %d svc_id = %d",attidx,conidx,svc_id);
	
	
if(len > 247)
{
ntf_att.data_len = 247;
ntf_att.p_data = data; 
gatt_notification(ntf_att);
ntf_att.data_len = len - 247;
ntf_att.p_data = data+247; 
gatt_notification(ntf_att);

}
else
{
ntf_att.data_len = len; 
//uint8_t tmp[len] = data; 
ntf_att.p_data = data; 
gatt_notification(ntf_att);
}

}
void BLE_To_UART(uint8_t *data,uint32_t len)
{
    uint32_t i=0;
    if(len == 0) return;
    for(; i<len; i++)
    {
        co_printf("%c",data[i]);
    }
    co_printf("\r\n");
}


void data(uint8_t att,uint8_t b,uint8_t c)
{
attidx = att;
conidx = b;
svc_id = c;
}
